<template>
  <div>
    <el-table
      v-loading="loading"
      ref="currencyTable"
      :data="tableData"
      stripe
      border
      style="width: 100%"
      @selection-change="getSelectVal"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" width="55" align="center">
      </el-table-column>
      <el-table-column prop="orderNumber" label="单据编号"></el-table-column>
      <el-table-column prop="docType" label="单据类型"></el-table-column>
      <el-table-column prop="applyTime" label="采购日期"> </el-table-column>
      <el-table-column prop="createTime" label="创建时间"></el-table-column>
    </el-table>
    <el-pagination
      class="pagination mt10"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      background
    >
    </el-pagination>
  </div>
</template>

<script>
import { getOrderList } from "@/api/system/purchase";
export default {
  data() {
    return {
      tableData: [],
      currentPage: 1, //当前页
      pageSize: 10, //每页条数
      total: 0,
      loading: false,
    };
  },
  methods: {
    //分页器size
    handleSizeChange(val) {
      this.pageSize = val;
      this.getDataList();
    },
    //分页器当前页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getDataList();
    },
    getSelectVal(val) {
      this.$emit("getSelectVal", val);
    },
    getDataList() {
      this.loading = true;
      getOrderList({ limit: this.pageSize, page: this.currentPage }).then(
        (res) => {
          this.tableData = res.data.records;
          this.total = res.data.total;
          this.loading = false;
        }
      );
    },
  },
  mounted() {
    this.getDataList();
  },
};
</script>

<style></style>
